home *** CD-ROM | disk | FTP | other *** search
- /**
- * Scout - The Amiga System Monitor
- *
- *------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * You must not use this source code to gain profit of any kind!
- *
- *------------------------------------------------------------------
- *
- * @author Andreas Gelhausen
- * @author Richard Körber <rkoerber@gmx.de>
- */
-
-
-
- #include "system_headers.h"
-
- APTR BT_ExpPrint,BT_ExpMore,BT_ExpExit;
- APTR exptext,explist;
- APTR expmoretext0,expmoretext1,expmoretext2,expmoretext3;
- APTR expmoretext4,expmoretext5,expmoretext6,expmoretext7;
- APTR expmoretext8,expmoretext9,expmoretext10,expmoretext1a;
- APTR ExpMoreGroup1,ExpMoreGroup2,ExpMoreAdd1,ExpMoreAdd2;
-
- static APTR ExpPool = NULL;
-
- __asm __saveds LONG explist_dspfunc(register __a2 char **array, register __a1 struct ExpEntry *expentry, register __a0 struct Hook *hook)
- {
-
- if (expentry) {
- *array++ = expentry->exp_address;
- *array++ = expentry->exp_boardaddr;
- *array++ = expentry->exp_type;
- *array++ = expentry->exp_manufname;
- *array = expentry->exp_complete_product;
- } else {
- *array++ = ESC "bAddress";
- *array++ = ESC "bBoardAddr";
- *array++ = ESC "bType";
- *array++ = ESC "bManufacturer";
- *array = ESC "bProduct";
- }
- return(0);
- }
-
- struct Hook explist_dsphook = {
- {NULL, NULL},
- (ULONG (* )())explist_dspfunc,
- NULL, NULL
- };
-
- void FreeExpansions (void)
- {
- MyFreePoolStructs (&ExpPool, exptext, NULL, explist);
- }
-
- int GetExpansions (struct ExpEntry **first) {
- struct ConfigDev *cd = NULL;
- struct ExpEntry *expentry,*previous = NULL;
-
- int expcnt = 0;
- *first = 0;
-
- if (!ExpPool) ExpPool = tbCreatePool(MEMF_CLEAR, 4096, 4096);
-
- if (clientstate) {
- if (SendDaemon ("GetExpList")) {
-
- while ((expentry = tbAllocPooled(ExpPool, sizeof(struct ExpEntry))) \
- && (ReceiveDecodedEntry ((UBYTE *) expentry, sizeof (struct ExpEntry)))) {
- IsHex (expentry->exp_address, (long *) &expentry->exp_adr);
-
- if (! *first)
- *first = expentry;
- if (previous)
- previous->exp_next = expentry;
-
- expcnt++;
- previous = expentry;
- }
- }
- } else {
- while ((cd = FindConfigDev (cd, -1, -1)) && (expentry = tbAllocPooled(ExpPool, sizeof(struct ExpEntry)))) {
- if (! *first)
- *first = expentry;
- if (previous)
- previous->exp_next = expentry;
-
- expentry->exp_adr = cd;
- _sprintf (expentry->exp_address, "$%08lx", cd);
- _sprintf (expentry->exp_flags, "$%02lx ", cd->cd_Flags);
- _sprintf (expentry->exp_boardaddr, "$%08lx", cd->cd_BoardAddr);
- _sprintf (expentry->exp_boardsize, "$%08lx", cd->cd_BoardSize);
- _sprintf (expentry->exp_type, "$%02lx ", cd->cd_Rom.er_Type);
- _sprintf (expentry->exp_product, "%02lx", cd->cd_Rom.er_Product);
- _sprintf (expentry->exp_manufacturer, "%04lx", cd->cd_Rom.er_Manufacturer);
- _sprintf (expentry->exp_serialnumber, "%lu", cd->cd_Rom.er_SerialNumber);
-
- if(IdentifyBase) {
- IdExpansionTags(IDTAG_ConfigDev,cd,
- IDTAG_ManufStr ,expentry->exp_manufname,
- IDTAG_ProdStr ,expentry->exp_prodname,
- IDTAG_ClassStr ,expentry->exp_prodclass,
- IDTAG_Localize ,FALSE,
- TAG_DONE);
- } else {
- strcpy(expentry->exp_manufname,"no identify.library");
- strcpy(expentry->exp_prodname,"???");
- expentry->exp_prodclass[0] = '\0';
- }
-
- _sprintf (expentry->exp_complete_product,"%s %s",expentry->exp_prodname, expentry->exp_prodclass);
-
- expcnt++;
- previous = expentry;
- }
- }
- return (expcnt);
- }
-
- void PrintExpansions (char *filename) {
- int i=1;
- BPTR handle;
- struct ExpEntry *entryp = NULL;
-
- handle = HandlePrintStart (filename);
- if (handle) {
- if (! WI_Expansions) {
- i = GetExpansions (&entryp);
- }
-
- strcpy (tmpstr, "\n Address Flags BoardAddr BoardSize Type Manuf. Prod. Serial#\n");
-
- if (PrintOneLine (handle, tmpstr) && i) {
- for (i=0;;i++) {
- if (WI_Expansions)
- DoMethod (explist,MUIM_List_GetEntry,i,&entryp);
- if (!entryp) break;
-
- _sprintf(tmpstr,"%s · %s %s",entryp->exp_manufname,entryp->exp_prodname,entryp->exp_prodclass);
- _sprintf(tmpstr2, "\n %s %s %s %s %s %s %s %9s\n Board = %s\n", entryp->exp_address, entryp->exp_flags, entryp->exp_boardaddr, entryp->exp_boardsize, entryp->exp_type, entryp->exp_manufacturer, entryp->exp_product, entryp->exp_serialnumber, tmpstr);
- if (! (PrintOneLine (handle, tmpstr2)))
- break;
-
- if (! WI_Expansions)
- entryp = entryp->exp_next;
- }
- }
- }
- HandlePrintStop();
- }
-
- void ShowExpansions (void) {
- struct ExpEntry *exp;
-
- ApplicationSleep();
- set(explist,MUIA_List_Quiet,TRUE);
- set(BT_ExpMore, MUIA_Disabled, TRUE);
-
- FreeExpansions();
- GetExpansions (&exp);
-
- while (exp) {
- InsertBottomEntry (explist, (APTR *) &exp);
- exp = exp->exp_next;
- }
-
- AwakeApplication();
- set(explist,MUIA_List_Quiet,FALSE);
- }
-
- void SendExpList (void) {
- struct ExpEntry *exp;
-
- FreeExpansions();
- GetExpansions (&exp);
-
- while (exp) {
- SendEncodedEntry ((UBYTE *) exp, sizeof (struct ExpEntry));
- exp = exp->exp_next;
- }
- FreeExpansions();
- }
-
- void GetExpansionMore (struct ConfigDev *exp) {
- unsigned char *title = "EXPANSION: ";
- struct WinFree *ptr;
- struct DiagArea *diag;
- int i;
- UBYTE ibyte,flags,type;
-
- UWORD cdflags[] = {CDF_SHUTUP, CDF_CONFIGME, CDF_BADMEMORY, CDF_PROCESSED, 0};
-
- char *cdtext[] = {"SHUTUP","CONFIGME", "BADMEMORY","PROCESSED"};
-
- UBYTE ertype[] = {ERTF_MEMLIST,ERTF_DIAGVALID, ERTF_CHAINEDCONFIG,0};
-
- char *ertypetext[] = {"MEMLIST","DIAGVALID", "CHAINEDCONFIG"};
-
- UBYTE erflags[] = {ERFF_MEMSPACE,ERFF_NOSHUTUP, ERFF_EXTENDED,ERFF_ZORRO_III,0};
-
- char *erflagstext[] = {"MEMSPACE","NOSHUTUP", "EXTENDED","ZORRO_III"};
-
- char *z3subsize[] = {"MATCHING","AUTO","64K","128K","256K","512K","1M","2M","4M", "6M","8M","10M","12M","14M","RESERVED","RESERVED"};
-
- if (ptr = AllocWinFree()) {
- ptr->wf_Window = (APTR) WindowObject,
-
- // MUIA_Window_SizeGadget, FALSE,
- MUIA_HelpNode, ExpansionsText,
- MUIA_Window_ID, MakeDetailID('.','E','X','P'),
- WindowContents, HGroup,
- Child, ExpMoreGroup1 = VGroup,
- Child, MyLabel2 ("Manufacturer:"),
- Child, MyLabel2 ("Product:"),
- Child, MyLabel2 ("Class:"),
- Child, MyLabel2 ("Address:\nBoardAddr:\nBoardSize:\nReserved03:"),
- Child, MyLabel2 ("Flags:"),
- Child, MyLabel2 ("er_Type:"),
- Child, MyLabel2 ("er_Flags:"),
- End,
- Child, ExpMoreGroup2 = VGroup, MUIA_Group_SameWidth, TRUE,
- Child, expmoretext0 = MyTextObject(),
- Child, expmoretext1 = MyTextObject(),
- Child, expmoretext1a = MyTextObject(),
- Child, HGroup,
- Child, expmoretext2 = MyTextObject2(),
- Child, MyLabel ("SlotAddr:\nSlotSize:\nInitDiagVec:\nSerialNumber:"),
- Child, expmoretext3 = MyTextObject2(),
- Child, MyLabel ("Driver:\nNextCD:\nUnused[4]:\nReserved[4]:"),
- Child, expmoretext4 = MyTextObject2(),
- End,
- Child, HGroup,
- Child, VGroup, MUIA_Group_SameWidth, TRUE,
- Child, expmoretext5 = MyTextObject2(),
- Child, expmoretext6 = MyTextObject2(),
- Child, expmoretext7 = MyTextObject2(),
- End,
- Child, VGroup, MUIA_Group_SameWidth, TRUE,
- Child, MyLabel2 (" = "),
- Child, MyLabel2 (" = "),
- Child, MyLabel2 (" = "),
- End,
- Child, VGroup, MUIA_Group_SameWidth, TRUE,
- Child, expmoretext8 = MyTextObject(),
- Child, expmoretext9 = MyTextObject(),
- Child, expmoretext10 = MyTextObject(),
- End,
- End,
- End,
- End, End;
-
- if (ptr->wf_Window) {
- MySetContents (expmoretext2, ESC "r$%08lx\n$%08lx\n$%08lx\n$%02lx", exp, exp->cd_BoardAddr, exp->cd_BoardSize, exp->cd_Rom.er_Reserved03);
- MySetContents (expmoretext3, ESC "r%ld\n%ld\n$%04lx\n%lu", exp->cd_SlotAddr, exp->cd_SlotSize, exp->cd_Rom.er_InitDiagVec, exp->cd_Rom.er_SerialNumber);
- MySetContents (expmoretext4, ESC "r$%08lx\n$%08lx\n$%08lx\n$%02lx%02lx%02lx%02lx", exp->cd_Driver, exp->cd_NextCD, exp->cd_Unused[4], exp->cd_Rom.er_Reserved0c, exp->cd_Rom.er_Reserved0d, exp->cd_Rom.er_Reserved0e, exp->cd_Rom.er_Reserved0f);
- MySetContents (expmoretext5, "$%02lx", exp->cd_Flags);
-
- tmpstr[0] = '\0';
- i = 0;
- while (cdflags[i]) {
- if (exp->cd_Flags & cdflags[i]) {
- if (strlen (tmpstr)) strcat (tmpstr, ", ");
- strcat (tmpstr, cdtext[i]);
- }
- i++;
- }
- MySetContents (expmoretext8, nonetest (tmpstr));
-
- type = exp->cd_Rom.er_Type;
- flags = exp->cd_Rom.er_Flags;
-
- MySetContents (expmoretext6, "$%02lx", type);
-
- tmpstr[0] = '\0';
- if (ibyte = type & ERT_TYPEMASK) {
- if (ibyte & ERT_ZORROIII) {
- strcat (tmpstr, "ZORROII");
- if (!(ibyte & 0x40))
- strcat (tmpstr, "I");
- strcat (tmpstr, ", ");
- }
- }
- i = 0;
- while (ertype[i]) {
- if (type & ertype[i]) {
- strcat (tmpstr, ertypetext[i]);
- strcat (tmpstr, ", ");
- }
- i++;
- }
-
- { /* MEMSIZE CALCULATION */
- UBYTE memsize;
-
- memsize = type & ERT_MEMMASK;
- strcat (tmpstr, "MEMSIZE=");
-
- if (flags & ERFF_EXTENDED) {
- if (memsize == 0x07) {
- strcpy (tmpstr2, "?");
- } else if (memsize == 0x06) {
- strcpy (tmpstr2, "1G");
- } else {
- i = (int) (1L<<memsize) * 16;
- _sprintf (tmpstr2, "%ldM", i);
- }
- } else {
- if (memsize == 0x00) {
- strcpy (tmpstr2, "8M");
- } else if (memsize < 0x05) {
- i = (int) (1L<<(memsize - 1)) * 64;
- _sprintf (tmpstr2, "%ldK", i);
- } else {
- i = (int) (1L<<(memsize - 5));
- _sprintf (tmpstr2, "%ldM", i);
- }
- }
- strcat (tmpstr, tmpstr2);
- MySetContents (expmoretext9, nonetest (tmpstr));
- }
-
- MySetContents (expmoretext7, "$%02lx", flags);
-
- tmpstr[0] = '\0';
- i = 0;
- while (erflags[i]) {
- if (flags & erflags[i]) {
- if (strlen (tmpstr) > 5)
- strcat (tmpstr, ", ");
- strcat (tmpstr, erflagstext[i]);
- }
- i++;
- }
-
- if (ERT_ZORROIII == type & ERT_TYPEMASK) {
- if (strlen (tmpstr) > 5)
- strcat (tmpstr, ", ");
- strcat (tmpstr, z3subsize[flags & 0x0f]);
- }
- MySetContents (expmoretext10, nonetest (tmpstr));
-
- if (type & ERTF_DIAGVALID) {
- DoMethod (ExpMoreGroup1,OM_ADDMEMBER,MyLabel2 ("DiagArea:\nda_Flags:"));
- DoMethod (ExpMoreGroup1,OM_ADDMEMBER,MyLabel2 ("da_Config:"));
-
- Child, ExpMoreAdd2 = VGroup, MUIA_Group_SameWidth, TRUE,
- Child, HGroup,
- Child, expmoretext4 = MyTextObject2(),
- Child, MyLabel ("da_Size:\nda_Name:"),
- Child, expmoretext5 = MyTextObject2(),
- Child, MyLabel ("da_DiagPoint:\nda_BootPoint:"),
- Child, expmoretext6 = MyTextObject2(),
- End,
- Child, HGroup,
- Child, expmoretext7 = MyTextObject2(),
- Child, MyLabel2 (" = "),
- Child, expmoretext8 = MyTextObject(),
- End,
- End;
- DoMethod (ExpMoreGroup2,OM_ADDMEMBER,ExpMoreAdd2);
-
- diag = (struct DiagArea *) ((char *) exp->cd_BoardAddr + exp->cd_Rom.er_InitDiagVec);
- MySetContents (expmoretext4, ESC "r$%08lx\n$%02lx", diag, diag->da_Flags);
- MySetContents (expmoretext5, ESC "r$%04lx\n$%04lx", diag->da_Size, diag->da_Name);
- MySetContents (expmoretext6, ESC "r$%04lx\n$%04lx", diag->da_DiagPoint, diag->da_BootPoint);
- MySetContents (expmoretext7, "$%02lx", diag->da_Config);
-
- strcpy (tmpstr, "BUSWIDTH=");
- ibyte = diag->da_Config;
- if (ibyte & DAC_WORDWIDE) {
- strcat (tmpstr, "WORDWIDE");
- } else {
- if (ibyte & DAC_BYTEWIDE)
- strcat (tmpstr, "BYTEWIDE");
- else
- strcat (tmpstr, "NIBBLEWIDE");
- }
-
- strcat (tmpstr, ", BOOTTIME=");
- if (ibyte & DAC_BINDTIME) {
- strcat (tmpstr, "BINDTIME");
- } else {
- if (ibyte & DAC_CONFIGTIME)
- strcat (tmpstr, "CONFIGTIME");
- else
- strcat (tmpstr, "NEVER");
- }
- set (expmoretext8, MUIA_Text_Contents, tmpstr);
- }
-
- if(IdentifyBase) {
- IdExpansionTags(IDTAG_ConfigDev,exp,
- IDTAG_ManufStr ,tmpstr,
- IDTAG_Localize ,FALSE,
- TAG_DONE);
- set (expmoretext0, MUIA_Text_Contents, tmpstr);
-
- IdExpansionTags(IDTAG_ConfigDev,exp,
- IDTAG_ClassStr ,tmpstr,
- IDTAG_Localize ,FALSE,
- TAG_DONE);
- set (expmoretext1a, MUIA_Text_Contents, tmpstr);
-
- IdExpansionTags(IDTAG_ConfigDev,exp,
- IDTAG_ProdStr ,tmpstr,
- IDTAG_Localize ,FALSE,
- TAG_DONE);
- set (expmoretext1, MUIA_Text_Contents, tmpstr);
- } else {
- set (expmoretext0, MUIA_Text_Contents, "[identify.library required]");
- }
-
- HandleWindowOpen (ptr, title, tmpstr);
- HandleWindowClose (ptr);
- }
- }
- }
-
-
- char expansions_title[WINDOWTITLELEN];
-
- void ExpansionsWindow (BOOL state) {
- if (state) {
- if (WI_Expansions) {
- ShowExpansions();
- } else {
- WI_Expansions = WindowObject,
- MUIA_Window_Title, MyGetWindowTitle (expansions_title, "EXPANSIONS"),
- MUIA_HelpNode, ExpansionsText,
- MUIA_Window_ID, MakeListID('E','X','P','A'),
- WindowContents, VGroup,
- Child, explist = MyListviewObject ("DELTA=8,DELTA=8,DELTA=8,,",&explist_dsphook),
- Child, exptext = MyTextObject(),
- Child, MyVSpace(2),
- Child, HGroup, MUIA_Group_SameSize, TRUE,
- Child, BT_ExpPrint = KeyButtonA (PrintText,ID_EXPPRINT),
- Child, BT_ExpMore = KeyButtonA (MoreText ,ID_EXPMORE),
- Child, BT_ExpExit = KeyButtonA (ExitText ,ID_EXPEXIT),
- End,
- End, End;
-
- DoMethod (AP_Scout,OM_ADDMEMBER,WI_Expansions);
- DoMethod (WI_Expansions,MUIM_Window_SetCycleChain,explist,BT_ExpPrint,BT_ExpMore,BT_ExpExit,NULL);
-
- SetCloseRequest (WI_Expansions,ID_EXPEXIT);
- SetListActive (explist,ID_EXPLV_ACTIVE);
- SetListviewDoubleClick (explist,ID_EXPMORE);
-
- ShowExpansions();
-
- SetWindowOpen (WI_Expansions,explist,ID_EXPEXIT);
- }
- } else if ((! state) && (WI_Expansions)) {
- SetWindowClose (WI_Expansions,TRUE);
-
- FreeExpansions();
-
- DoMethod (AP_Scout,OM_REMMEMBER,WI_Expansions);
- MUI_DisposeObject (WI_Expansions);
- WI_Expansions = NULL;
- explist = NULL;
- }
- }
-
-